package com.wells.slide;

import com.wells.slide.activity.Login;
import com.wells.slide.activity.Main;
import com.wells.slide.activity.More;
import com.wells.slide.utils.Const;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

public class Intro extends Activity
{

    private Context                  mContext = null;
    private SharedPreferences        mPrefs;
    private SharedPreferences.Editor mEditor;
    private String                   mMyId    = "";

    @Override
    protected void onCreate( Bundle savedInstanceState )
    {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.intro );

        mContext = this;

        mPrefs = mContext.getSharedPreferences( Const.PREFERENCE_NAME,
                                                Context.MODE_PRIVATE );

        mMyId = mPrefs.getString( Const.PREFS_ID, "" );

        new CheckLoginTask().execute();
        
    }

    class CheckLoginTask extends AsyncTask<Void, Void, String>
    {

        @Override
        protected void onPreExecute()
        {
            super.onPreExecute();
        }

        @Override
        protected String doInBackground( Void... params )
        {
            String result = null;

            try
            {
                Thread.sleep( 2000 );
            }
            catch ( InterruptedException e )
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return result;
        }

        @Override
        protected void onPostExecute( String result )
        {

            // 로그인 아이디 정보가 없으면 로그인 페이지로 이동
            if ( mMyId.equals( "" ) )
            {
                Intent intent = new Intent( mContext, Login.class );
                startActivity( intent );
                finish();
            }
            // 아이디가 있으면 바로 로그인 시킴
            else
            {
                Intent intent = new Intent( mContext, More.class );
                startActivity( intent );
                finish();
            }
           
        }
    }

}
